package cc.wanforme.chipmunity.system.service;

import org.springframework.stereotype.Service;

import cc.wanforme.chipmunity.common.bean.WebResponse;
import cc.wanforme.chipmunity.system.mapper.TopPassageMapper;
import cc.wanforme.chipmunity.system.po.TopPassage;
import cc.wanforme.chipmunity.system.service.interfaces.TopPassageService;

/**
 * @author wanne
 * 2019年8月18日
 * 
 */
@Service
public class TopPassageServiceImpl implements TopPassageService{

	private TopPassageMapper topPassageMapper;

	@Override
	public WebResponse addTopPassage(TopPassage topPassage) {
		if(topPassage.getSubjectId()==null || topPassage.getPassageId()==null || topPassage.getEndTime()==null) {
			return WebResponse.fail("信息不完整");
		}
		
		TopPassage topPassage_persistent = new TopPassage(topPassage.getSubjectId(), 
				topPassage.getPassageId(), topPassage.getSortSign(), topPassage.getEndTime());
		topPassageMapper.insertTopPassage(topPassage_persistent);
		return WebResponse.success("添加成功");
	}
	
	@Override
	public WebResponse updateTopPassage(TopPassage topPassage) {
		if(topPassage.getId() == null) {
			return WebResponse.fail("未知置顶文章");
		}
		
		topPassageMapper.updateTopPassage(topPassage);
		return WebResponse.success("更新成功");
	}
	
	
}
